package com.iqismart.shorturl.model;

import com.iqismart.shorturl.vo.LogResponse;
import org.springframework.beans.BeanUtils;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;

/**
 * @Description
 * @Auther sty
 * @createTime 2019-10-14 11:19
 */
@Entity
@Table(indexes = {@Index(name="urlIdIndex", columnList="urlId"),
        @Index(name="ipIndex", columnList="ip"),
        @Index(name="clientTypeIndex", columnList="clientType"),
        @Index(name="ipCityIndex", columnList="ipCity")} )
public class EntityLog extends BaseEntity<LogResponse> {
    private Long urlId;
    private String userAgent = "";
    @Column(columnDefinition = "varchar(10)")
    private String clientType = "";
    private String referer = "";
    @Column(columnDefinition = "varchar(20)")
    private String ip = "";
    @Column(columnDefinition = "varchar(10)")
    private String ipCity = "";

    private Long uid = 0L;

    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    public String getClientType() {
        return clientType;
    }

    public void setClientType(String clientType) {
        this.clientType = clientType;
    }

    public Long getUrlId() {
        return urlId;
    }

    public void setUrlId(Long urlId) {
        this.urlId = urlId;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getReferer() {
        return referer;
    }

    public void setReferer(String referer) {
        this.referer = referer;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getIpCity() {
        return ipCity;
    }

    public void setIpCity(String ipCity) {
        this.ipCity = ipCity;
    }

    @Override
    public LogResponse toResponse() {
        final LogResponse response = new LogResponse();
        BeanUtils.copyProperties(this,response);
        return response;
    }
}
